use alloc::string::String;

use crate::arch::module::load_other_module;

use super::{SysResult, Syscall};

impl Syscall<'_> {
    pub fn sys_load_module(&mut self, path_ptr: usize, path_len: usize, args: usize) -> SysResult {
        let buf = unsafe { core::slice::from_raw_parts(path_ptr as *const u8, path_len) };
        let path = unsafe { String::from_utf8_unchecked(buf.to_vec()) };
        load_other_module(&path, unsafe {
            *(args as *const Option<(usize, usize, usize, usize, usize, usize)>)
        });
        Ok(0)
    }
}
